import Taro, { Component } from '@tarojs/taro'
import { View, ScrollView } from '@tarojs/components'
import { AtTabs, AtTabsPane } from 'taro-ui'
import { DNavBar, Dmorinfo, DItemError, DModal } from '@/components'
import MortageList  from './MortageList'
import http from '@/api'
import common from '@/common'
import '../index/index.scss'
import './mortgage.scss'
export default class Index extends Component {

  constructor(props) {
    super(props)
    this.state = {
      active: 0,
      isShow: false,
      scrollHeight: window.screen.availHeight,
      id: '',
      handle: '',
      currPage: 1,
      totalPage: 1,
      pageSize: 10,
      status: false,
      list: [],
      itemId: ''
    }
  }

  componentWillMount() {
    // this.httpMySearchCarList()
    let { active = 0 } = this.$router.params
    // this.handleClick(+active)
  }
  componentDidShow() {
    this.setState({
      list: [],
      currPage: 1,
      totalPage: 1,
      status: false
    }, () => {
      // this.httpMySearchCarList()
    })
  }
  //寻车详细
  handleDetail(item) {
    let { active } = this.state
    if (active === 1) {
      return Taro.showToast({
        title: '该寻车已过期',
        icon: 'none'
      })
    }
    Taro.navigateTo({
      url: `/pages/detail/detail?id=${item.id}&status=${active + 1}`
    })
  }
  //切换tab
  handleClick(active) {
    this.setState({
      list: [],
      currPage: 1,
      totalPage: 1,
      active,
      status: false
    })
  }
  render() {
    const tabList = [{ title: '审核中' }, { title: '已完结' }]
    const {
      active,
      list,
      isShow,
      handle,
      scrollHeight,
      status
    } = this.state
    return (
      <View className='b_index b_mortgage'>
        <DNavBar title={'我的按揭'}></DNavBar>
        <View className='b_index__box'>
          <View className='b_index__content'>
            <AtTabs tabDirection='horizontal' swipeable={true} current={active} tabList={tabList} onClick={this.handleClick.bind(this)}>
              <AtTabsPane />
            </AtTabs>
            <MortageList active={active} />
          </View>
        </View>
        </View>
    )
  }
}
